<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" href="../../css/reset.css" />
		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body class="ly-bgcolor">
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">支付密码修改</p>
				</div>
				<div id="content" style="padding-bottom: 1.319444rem;">
					<div class="ly-form">
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">填写旧密码</label>
							<div class="col-xs-8"><input class="form-control" id="pwd" maxlength="6" type="password" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">填写新密码</label>
							<div class="col-xs-8"><input class="form-control" id="pwd1" maxlength="6" type="password" /></div>
						</div>
						<div class="form-group row">
							<label class="control-label col-xs-3 ly-form-label" style="text-align: right;">确定密码</label>
							<div class="col-xs-8"><input class="form-control" / id="repwd" maxlength="6" type="password"></div>
						</div>
						<div class="row">
							<a style="color: #fff;" class="ly-borderp col-xs-3" id="sure">确定</a>
							<a style="color: #fff;" class="ly-borderp col-xs-3" id="cancle">取消</a>
						</div>
					</div>
				</div>
			</div>
		</div>

	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}

		$(function() {
			var local = 'http://47.104.13.109/member-service';
			$("#cancle").on("click", function() {
				history.go(-1);
			})

			$("#sure").on('click', function() {
				console.log($.cookie('tokenRh'))
					//密码一致
				var oldPwd = $("#pwd").val();
				var pwd = $("#pwd1").val();
				var repwd = $("#repwd").val();
				if(repwd != pwd) {
					alert("两次密码不一致!");
					$("#repwd").val("");
				} else {
					$.ajax({
						type: "post",
						url: local + '/auth/security/pwd',
						async: true,
						data: {
							'oldPassword': oldPwd,
							'newPassword': pwd,
							'rePassword': repwd,
							'passwordType': 'pay',
							'token': $.cookie('tokenRh')
						},
						success: function(res) {
							console.log(res);
							if(res) {
								alert("密码更改成功");
								history.go(-1);
							} else {
								alert("密码更改失败");
							}
						},
						error: function(error) {
							console.log(error);
							var s = JSON.parse(error.responseText);
							alert(s.error_message);
						}
					});

				}

			})

		})
	</script>

</html>